package com.kingdee.pda.ui.scan_inwarehouse;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.kingdee.pda.R;
import com.kingdee.pda.entity.Warehouse;
import com.kingdee.pda.ui.activity.BaseTitleActivity;
import java.io.Serializable;
import java.util.List;

import butterknife.BindView;

/**
 * 扫描收货详情界面
 * * Created by dlj
 * DATE 2021/11/10
 * TIME 10:20
 */
public class ScanReceiveDetailActivity extends BaseTitleActivity {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    @BindView(R.id.scan_total)
    TextView scan_total;

    @BindView(R.id.wait_scan_total)
    TextView wait_scan_total;

    private List<ScanReceiveShowDetailBean> detailBeans;//整个快递单/ASN单所有的详情
    private ScanReceiveDetailAdapter adapter;

    public static void actionStart(Context context, List<ScanReceiveShowDetailBean> detailBeans) {
        Intent intent = new Intent(context, ScanReceiveDetailActivity.class);
        intent.putExtra("detailBeans", (Serializable) detailBeans);
        context.startActivity(intent);
    }

    @Override
    public void changeWarehouse(Warehouse warehouse) {

    }


    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        super.onActivityCreate(savedInstanceState);
        setContentView(R.layout.layout_simple_recyclerview_activity);
    }

    @Override
    protected void initView() {
        super.initView();
        setTitle("收货详情");
    }

    @Override
    protected void initData() {
        super.initData();
        detailBeans = (List<ScanReceiveShowDetailBean>) getIntent().getSerializableExtra("detailBeans");

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new ScanReceiveDetailAdapter(this, detailBeans);
        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
        recyclerView.setAdapter(adapter);

        int total = 0;
        int wait_total = 0;
        for (ScanReceiveShowDetailBean showDetailBean : detailBeans) {
            total += showDetailBean.getScannedqty();
            wait_total += (showDetailBean.getPalnqty() - showDetailBean.getReceiptedqty());
        }
        scan_total.setText(total + "");
        wait_scan_total.setText(wait_total + "");
    }
}
